package com.happy.main.controller;

import com.happy.core.dto.WeiXinDTO;
import com.happy.main.constant.WebConstants;
import com.happy.main.menu.model.MenuVO;
import com.happy.main.pagemodel.BaseResult;
import com.happy.main.pagemodel.ListResult;
import com.happy.main.wexin.WeiXinAPI;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;

/**
 * @description: 微信小程序注册登录接口
 * @author: xinhuan.tao
 * @time: 2020/4/2 0002 14:54
 */
@RestController
@Api(value = "微信接口", tags = "微信接口")
public class WexinController {

    @Autowired
    private WeiXinAPI weiXinAPI;

    @PostMapping("/templates/wexin/regist")
    public BaseResult WeixinRegist(@RequestBody WeiXinDTO query) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
        ListResult<MenuVO> page = new ListResult<>();
        weiXinAPI.login(query);
        System.out.println(query);
        page.setResult(WebConstants.RESULT_SUCCESS);
        return page;
    }


}
